﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MaxStudio.Concrete.WebSite.Models.FunctionesModels>" %>
<%@ Import Namespace="MaxStudio.Concrete.Server.Dao" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Functiones
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <%--   <div style="background-color: #f5f5f5; margin:10px; border: thin solid  #ffd18c">
            sd
        </div>--%>
         
         
        <div>
            >>我的位置 >> 用户管理 >> 权限组管理
        </div>
        <div>
            <div id="tabs">
                <ul>
                    <li><a href="#tabs-1">功能介绍</a></li>
                    <li><a href="#tabs-2">权限组管理</a></li>
                </ul>
                <div id="tabs-1">
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
                    incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
                    exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div>
                <div id="tabs-2">
                    <div style="width: auto; margin: 10px;">
                        <p>
                            <a href="#" id="dialog_link" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-newwin">
                            </span>添加权限组</a></p>
                        <!-- ui-dialog -->
                        <div id="dialog" title="权限组添加">
                            <p> 
                       <% using (Html.BeginForm()) {%>
                        <%= Html.ValidationSummary(true) %>
                                    <div style="  width:100%;">
                                           <div style="float:left; width:100%"> 
                                                  用户组名称 
                                                    <%= Html.TextBoxFor(model => model.GroupName) %>
                                                    <%= Html.ValidationMessageFor(model => model.GroupName) %>
                                            </div>
                                            <div style="float:left; width:100%; margin-top:20px;"> 
                                              <% List<tb_FunctionItem> objList = ViewData["FunctionItems"] as List<tb_FunctionItem>;%>  
                                                    <%
                                                        var dropList = new List<CheckBox>();
                                                        foreach (tb_FunctionItem FI in objList)
                                                        {
                                                            var dropItem = new CheckBox();
                                                            dropItem.Text = FI.Name.ToString(); %>
                                                    <%= Html.CheckBox("checkBox",new { id="myCheckBox" })%>
                                                    <%= Html.Encode(FI.Name)  %>
                                                    <%  } 
                                                    %>
                                            </div>
                                            <div style="float:left; width:100%; margin-top:20px; text-align:right;"> 
                                                <input type="submit" value="submit" />
                                                <input  type="reset" value="Reset" />
                                            </div>
                                    </div> 
                             <% } %>
                                    </p> 
                        </div>
                        
          
    <!-- Eidt ui-dialog -->
    	<script>
    	    // increase the default animation speed to exaggerate the effect
    	    $.fx.speeds._default = 1000;
    	    $(function() {
    	    $("#Div1").dialog({
    	            autoOpen: false 
    	        });

    	        $("#opener").click(function() {
    	        $("#Div1").dialog("open");
    	            return false;
    	        });
    	    });
	</script>
                    
                  <div id="Div1" title="ED">
                            <p> 
                       <% using (Html.BeginForm()) {%>
                        <%= Html.ValidationSummary(true) %>
                                    <div style="  width:100%;">
                                           <div style="float:left; width:100%"> 
                                                  ss用户组名称 
                                                    <%= Html.TextBoxFor(model => model.GroupName) %>
                                                    <%= Html.ValidationMessageFor(model => model.GroupName) %>
                                            </div>
                                            <div style="float:left; width:100%; margin-top:20px;"> 
                                              <% List<tb_FunctionItem> objList = ViewData["FunctionItems"] as List<tb_FunctionItem>;%>  
                                                    <%
                                                        var dropList = new List<CheckBox>();
                                                        foreach (tb_FunctionItem FI in objList)
                                                        {
                                                            var dropItem = new CheckBox();
                                                            dropItem.Text = FI.Name.ToString(); %>
                                                    <%= Html.CheckBox("checkBox",new { id="myCheckBox" })%>
                                                    <%= Html.Encode(FI.Name)  %>
                                                    <%  } 
                                                    %>
                                            </div>
                                            <div style="float:left; width:100%; margin-top:20px; text-align:right;"> 
                                                <input type="submit" value="submit" />
                                                <input  type="reset" value="Reset" />
                                            </div>
                                    </div> 
                             <% } %>
                                    </p> 
                        </div>      

                     <div> 
                     <table id="customers" style="display:none"></table>
         <script type="text/javascript"> 
             $("#customers").flexigrid(
             { 
                 url: '/FunctionItems/FlexigridList',
                 dataType: 'json',
                  
                colModel: [
                            {display: 'ID', name: 'Id', width: 40, sortable: true, align: 'left'},
                            { display: 'Name', name: 'Name', width: 100, sortable: true, align: 'left' }
                    ],
                    buttons: [
                                { name: 'add', displayname: '新增', bclass: 'add', onpress: toolbarItem },
            { name: 'modify', displayname: '修改', bclass: 'modify', onpress: toolbarItem },
            { name: 'delete', displayname: '删除', bclass: 'delete', onpress: toolbarItem },  
                                {
                                    separator: true
                                }  
                             ],
                searchitems: [
                    { display: 'Name', name: 'Name' } 
                    ],
                sortname: 'Id',
                sortorder: 'asc',
                usepager: true,
                title: 'Customers',
                useRp: true,
                rp: 15,
                showTableToggleBtn: true,
                pagestat: '显示 {from} 到 {to}， 共 {total} 条',
                nomsg: '没有数据',
                procmsg: '请等待数据正在加载中…',
                width: 500,
                height: 380, 
                singleSelect:true//只能单选 
              }
              );
              function toolbarItem(com, grid) {
                  if (com == 'delete') {
                      if ($('.trSelected', grid).length == 0) {
                          alert("请选择要删除的数据");
                      } else {
                          if (confirm('是否删除这 ' + $('.trSelected', grid).length + ' 条记录吗?')) {
                              var ids = "";
                              for (var i = 0; i < $('.trSelected', grid).length; i++) {
                                  ids += "," + $('.trSelected', grid).find("td:eq(2)").eq(i).text(); //获取id,td:eq(2)  
                              }
                              idsids = ids.substring(1);
                              $.ajax({
                                  type: "POST",
                                  url: "flexGridServlet.do?action=delete",
                                  data: "id=" + ids,
                                  dataType: "text",
                                  success: function(msg) {
                                      if (msg == "success") {
                                          $("#customers").flexReload();
                                      } else {
                                          alert("有错误发生,msg=" + msg);
                                      }
                                  },
                                  error: function(msg) {
                                      alert("msg=" + msg);
                                  }
                              });
                          }
                      }
                  } else if (com == 'add') {
                  alert("flexGridServlet.do?action=add");  
                      $("#Div1").dialog("open"); 
                   
                  } else if (com == 'modify') {
                      if ($(".trSelected").length == 1) {
                          window.location.href = "flexGridServlet.do?action=modify&id=" + $('.trSelected', grid).find("td").eq(2).text();
                      } else if ($(".trSelected").length > 1) {
                          alert("请选择一个修改,不能同时修改多个");
                      } else if ($(".trSelected").length == 0) {
                          alert("请选择一个您要修改的记录")
                      }
                      //$("#flex1").flexReload({});  
                  }
              }
              
        </script>
    
                                     

                     <%-- <table id="flexme1">
                         <thead>
                                <tr>
                                    <th width="200">
                                        自编号
                                    </th>
                                    <th width="200">
                                        权限组名称
                                    </th>
                                    <th width="200">
                                        管理
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>
                                        This is data 1 with overflowing content
                                    </td>
                                    <td>
                                        This is data 2
                                    </td>
                                    <td>
                                        进入管理
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        This is data 1
                                    </td>
                                    <td>
                                        This is data 2
                                    </td>
                                    <td>
                                        进入管理
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                        <script type="text/javascript">
		        //<![CDATA[
		        jQuery(document).ready(function($) {
			        $('#flexme1').flexigrid();
		        });
		        //]]>
		        </script> --%>
                    </div>
                    <div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
